#!/usr/bin/env python
# Copyright(c) 2009 GHCM Ltd. All rights reserved.

from mahbo.lib import (PHD,)

import os


class CDHIT_Python(object):
    
    def __init__(self,**kwargs):
        self.infile     = ''
        self.indentity  = 0.98
        self.__dict__.update(kwargs)
        self.useInfile  = ''
        self.outfile    = ''
        
    def run(self):
        self.useInfile  = os.path.join(PHD.gutmtps.cluster,'uclust\\%s' % self.infile)
        self.outfile    = self.useInfile.replace('.','_out.')
        inread          = open(self.useInfile,'r')
        indata          = inread.read()
        indatam         = indata.replace('\f','')
        indatam         = indatam.replace('\r','\n')
        newwrite        = open(self.outfile,'w')
        newwrite.write(indatam)
        newwrite.close()


if __name__ == '__main__':
#    testfile    = 'test.txt'
    testfile    = 'ibdmtps_raw.fasta'
    c           = CDHIT_Python(infile     = testfile  ,
                               indentity  = 0.99      ,
                               )
    c.run()
    
    
    
    